package com.naiterui.ehp.bp.support.exception;

import static com.naiterui.ehp.bp.support.message.MessageContext.message;

import lombok.Getter;

/**
 * 自定义异常基类
 * <P>File name : BaseException.java </P>
 * <P>Author : zhouyanxin </P>
 * <P>Date : 2014-9-29 </P>
 */
@Getter
public abstract class BaseException extends Exception {

    /**
     * 字段或域定义：<code>serialVersionUID</code>
     */
    private static final long serialVersionUID = -7094081888791936121L;

    /**
     * 异常
     */
    private int code;
    private Object data;

    public BaseException(String msg) {
        super(msg);
    }

    public BaseException(String msg, Throwable cause) {
        super(msg, cause);
    }

    public BaseException(int code) {
        this(message(code));
        this.code = code;
    }

    public BaseException(int code, Throwable cause) {
        this(message(code), cause);
        this.code = code;
    }

    public BaseException(int code, String msg) {
        this(msg);
        this.code = code;
    }

    public <T> BaseException(int code, String msg, T data) {
        this(msg);
        this.code = code;
        this.data = data;
    }

    public BaseException(int code, String msg, Throwable cause) {
        this(msg, cause);
        this.code = code;
    }

}
